(function(){
	Ext.onReady(function(){
		
		/**
		 * 定义一个types变量，为下面取得模型属性的类型
		 */
		var types = Ext.data.Types;
		/**
		 * 定义Emp模型
		 */
		Ext.define("Emp",{
			extend: 'Ext.data.Model',
			fields:[
			{name:'empno',type:types.INT},
			{name:'ename',type:types.STRING},
			{name:'job',type:types.STRING},
			{name:'mgr',type:types.INT},
			{name:'hiredate',type:types.DATE},
			{name:'sal',type:types.FLOAT},
			{name:'comm',type:types.FLOAT},
			{name:'deptno',type:types.INT}
			]
		});
		
		/**
		 * 创建一个数据集
		 */
		var empStore = Ext.create("Ext.data.Store",{
			storeId:'empStore',
			model:'Emp',
			autoLoad:true,
			proxy:{
				type:'ajax',
				url:'getemplist',
				reader:{
					type:'json',
					root:'data'
				}
			}
		});
		//创建面板
		Ext.create("Ext.grid.Panel",{
			title:'员工列表',
			width:800,
			height:600,
			renderTo:Ext.getBody(),
			store:empStore,
			columns:[
			{text: '员工编号',  dataIndex:'empno'},
			{text: '姓名',  dataIndex:'ename'},
			{text: '工作职位',  dataIndex:'job'},
			{text: '直接上司编号',  dataIndex:'mgr'},
			{text: '月薪',  dataIndex:'sal'},
			{text: '奖金',  dataIndex:'comm'},
			{text: '所在部门编号',  dataIndex:'deptno'}
			]
		});
	});

})();